package com.wisemoresystem.seal.action.word;

import java.util.List;
import java.util.Map;

import org.ne.framework.data.util.ChkTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.wisemoresystem.seal.base.action.ProjBaseAction;
import com.wisemoresystem.seal.base.tip.Tip;
import com.wisemoresystem.seal.model.t_word_type;
import com.wisemoresystem.seal.service.WordService;

/**
 * 文种词管理
 * 
 * @author Administrator
 *
 */
@Controller("ixWordType")
@Scope("prototype")
@RequestMapping("/ix/word")
public class WordTypeAction extends ProjBaseAction {

	@Autowired
	private WordService wService;

	@RequestMapping("/list")
	public ModelAndView list() {

		List<Map<String, Object>> list = wService.selectWordTypeList();

		ModelAndView mv = new ModelAndView("/jsp/word/word/list");
		mv.addObject("list", list);
		return mv;
	}

	@RequestMapping("/add")
	public ModelAndView add(t_word_type wt, String word_id) {
		
		if (ChkTools.isNull(word_id)) {
			oc.saveObj(wt);
		} else {
			t_word_type t = oc.findObjById(word_id, t_word_type.class);
			t.setName(wt.getName());
			oc.updateObj(t);
		}
		
		super.setTipMsg("操作成功！", Tip.Type.success);
		ModelAndView mv = new ModelAndView("redirect:list.htm");
		return mv;
	}
	
	@RequestMapping("/del")
	public ModelAndView del(String word_id) {

		oc.delObjById(word_id, t_word_type.class);

		super.setTipMsg("操作成功！", Tip.Type.success);
		ModelAndView mv = new ModelAndView("redirect:list.htm");
		return mv;
	}
}
